package com.qq.servlet;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.qq.bean.Comment;
import com.qq.service.CommentService;
import com.qq.service.impl.CommentServiceImpl;

@WebServlet("/CommentSelect.do")
public class CommentSelectAll extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int dynamics_id = Integer.parseInt(request.getParameter("dynamics_id"));
		CommentService cm = new CommentServiceImpl();
		Map<String,Object> allcomment = cm.selectAllcomment(dynamics_id);
		//System.out.println(allcomment.get(dynamics_id));
		ObjectMapper mapper = new ObjectMapper();
		String json = mapper.writeValueAsString(allcomment);
		response.setContentType("application/json;charset=utf-8");
		mapper.writeValue(response.getWriter(), json);
	}

}
